package server.main.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import server.main.config.cache.MybatisPlusRedisCache;
import server.main.pojo.Account;
import server.main.pojo.Role;

import java.util.List;


/**
 * @auther MingHsZzz
 * @Date 2022/9/7-12:33
 */

@Mapper
@CacheNamespace(implementation = MybatisPlusRedisCache.class)
public interface AccountMapper extends BaseMapper<Account> {

    //还在用username查，后面可能需要改成jobbum
    @Select("select * from server_account where doctor_jobnum=#{jobnum}")
    public Account loadUserByJobnum(String jobnum);


    @Select("select r.id,r.name,r.nameZh from role r,account_role ar where r.id=ar.role_id and ar.server_account_jobnum=#{jobnum}")
    public List<Role> getUserRolesByJobnum(String jobnum);



    @Select("delete from server_account where doctor_jobnum = #{jobnum}")
    public void deleteByJobnum(String jobnum);
}




